package com.wsm.util.httpclient.proxy;

import com.wsm.util.httpclient.config.LogConfig;
import org.springframework.beans.factory.FactoryBean;

/**
 * @author ：wangshimin
 * @date ：Created in 2021-02-27 下午 09:16
 * @description：
 * @version:
 */
public class HttpRequestProxyFactory<T> implements FactoryBean<T> {

    private Class<T> interfaceClass;

    private LogConfig logConfig;

    private Integer retryCount;

    private String baseUrl;

    @Override
    public T getObject() {
        return (T) new HttpRequestProxy(interfaceClass, logConfig, retryCount, baseUrl).proxy();
    }

    @Override
    public Class<?> getObjectType() {
        return interfaceClass;
    }

    @Override
    public boolean isSingleton() {
        // 单例模式
        return true;
    }

    public Class<T> getInterfaceClass() {
        return interfaceClass;
    }

    public void setInterfaceClass(Class<T> interfaceClass) {
        this.interfaceClass = interfaceClass;
    }

    public LogConfig getLogConfig() {
        return logConfig;
    }

    public void setLogConfig(LogConfig logConfig) {
        this.logConfig = logConfig;
    }

    public Integer getRetryCount() {
        return retryCount;
    }

    public void setRetryCount(Integer retryCount) {
        this.retryCount = retryCount;
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }
}
